package com.yfl.tingyu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yfl.tingyu.pojo.Planner;
import com.yfl.tingyu.mapper.PlannerMapper;
import com.yfl.tingyu.service.IPlannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2020-05-29
 */
@Service
public class PlannerServiceImpl extends ServiceImpl<PlannerMapper, Planner> implements IPlannerService {

    @Override
    public Map<String, Object> selectIPlanner(Integer page, Integer rows, Integer cid) {
        //创建分页对象
        IPage<Map<String,Object>> iPage=new Page<>(page,rows);

        //创建条件查询对象
        QueryWrapper qw=new QueryWrapper();
        qw.eq("cid",cid);

        IPage<Map<String,Object>> planner = baseMapper.selectMapsPage(iPage, qw);

        //封装dataGride需要的数据
        Map<String,Object> map=new HashMap<>();
        map.put("total",planner.getTotal());
        map.put("rows",planner.getRecords());

        return map;
    }
}
